package cn.kgm.makeGod.condition;

import cn.kgm.makeGod.Character;
import cn.kgm.makeGod.action.Action;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-9-11 11:32
 * @Description: cn.kgm.makeGod.condition.GameEvent
 */

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GameEvent {
    private int id;
    private String name;
    private int triggerChance;
    private List<Condition> conditions = new ArrayList<>();
    private List<Action> actions = new ArrayList<>();

    public GameEvent(int id, String name, int triggerChance) {
        this.id = id;
        this.name = name;
        this.triggerChance = triggerChance;
    }

    public boolean checkConditions(Character actor, Character target, WorldState world) {
        for (Condition condition : conditions) {
            if (!condition.check(actor, target, world)) {
                return false;
            }
        }
        return true;
    }

    public void executeActions(Character actor, Character target, WorldState world, EventResult result) {
        for (Action action : actions) {
            action.execute(actor, target, world, result);
        }
    }
}
